import React, { useState, useRef } from "react";
import Son from "./Son";

export default function Index() {

  const textRef = useRef(null);
  const sonRef = useRef(null);
 
  const getTest01=()=>{
    // textRef.current
    console.log("textRef.current",textRef.current);
    console.log("textRef.current.value",textRef.current.value);
  }

  const getTest02=()=>{
    console.log("sonRef.current",sonRef.current);
    sonRef.current.chuan("hello，我是父亲");
  }

  return (
    <div>
      <h1>useRef</h1>
      <input type="text"  ref={textRef} />
      <input type="button" value="测试01" onClick={getTest01} />
      <Son ref={sonRef} />
      <input type="button" value="测试02" onClick={getTest02} />
    </div>
  );
}
